package 多线程.虚假唤醒;

// 补货线程
public class PlusThread implements Runnable {
 
    private MyService myService;
 
    public PlusThread(MyService myService) {
        this.myService = myService;
    }
 
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            myService.plus();
        }
    }
    // 售货线程
    public static class SubThread implements Runnable {

        private MyService myService;

        public SubThread(MyService myService) {
            this.myService = myService;
        }

        @Override
        public void run() {
            for (int i = 0; i < 10; i++) {
                myService.sub();
            }
        }
    }
}
 
